<?php
/**
 * 显示文章
 * 
 * ============================================================================
 * 版权所有: (c) 2009-2011，<UEShop Inc>，并保留所有权利。
 * 网站地址: http://www.ueshop.cn
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和使用；
 * 不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
 *
 * @author      cmpan
 * @copyright   Copyright (c) 2009-2010 UEShop Inc. (http://www.ueshop.cn)
 * @license     http://www.ueshop.cn/1_0.txt
 */
class ShowController extends UE_Controller_Action {	
	public function listAction() {		
	    if (empty($this->id)) {
	    	header('Location:'.UE::context());
	    	return ;
	    }	    
	    
	    if ($this->id == 'unclassified') {
		    $cat = array();
		    $cat['cat_id'] = 0;
		    $cat['cat_name'] = '未分类';
		    $cat['cat_list_tpl'] = 'info/show.list';
		    $cat['cat_url'] = UE_Url::make('info/show/list/unclassified');
		    $cat['hasChile'] = false;
	    } else {
	    	$cat = $this->tpl->cats[$this->id];
	    }
	    
	    $sql = "SELECT * FROM ue_info WHERE cat_id='{$cat['cat_id']}' LIMIT";
	    //print_r($this->tpl->cats);
	    
	    $tpl = $cat['hasChile'] ? $cat['cat_tpl'] : $cat['cat_list_tpl'];
	    $this->tpl->apply($tpl);
	}
	
	public function itemAction() {
	    if (empty($this->id)) {
	    	print "Error Param!";
	    	return ;
	    }
	    
	    $sql = "SELECT * FROM ue_info WHERE info_id='{$this->id}' LIMIT 1";
	    $item = UE_DB::factory()->getAll($sql);
	    
	    if ($item) {
	    	$sql = "SELECT info_content FROM ue_info_content WHERE info_id='{$this->id}' LIMIT 1";
	    	$item['info_content'] = UE_DB::factory()->getfirstField($sql);
	    }
	    
	    print_r($item);
	}	
}